<!--
 * @Description: 
 * @Author: xiongkuobiao
 * @Date: 2023-02-21 21:26:16
 * @LastEditors: xiongkuobiao
 * @LastEditTime: 2023-02-21 21:36:58
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    Array.prototype.myMap = function (fn) {
      let res = [];
      for (let i = 0; i < this.length; i++) {
        res.push(fn(this[i]));
      }
      return res;
    };

    let arr = [{ name: 111 }, { name: 222 }];
    console.log(
      arr.myMap((item) => {
        return { age: item.name };
      })
    );
  </script>
</html>
